package visitor.pattern.simple.computer;

import visitor.pattern.simple.computer.kinds.ComputerPart;
import visitor.pattern.simple.computer.kinds.Keyboard;
import visitor.pattern.simple.computer.kinds.Monitor;
import visitor.pattern.simple.computer.kinds.Mouse;
import visitor.pattern.simple.computer.visitors.ComputerPartVisitor;

/**
 * @Author: Coderlyz
 * @Date: 2023/3/29 14:36
 */
public class Computer implements ComputerPart {

    ComputerPart[] parts;

    public Computer(){
        parts = new ComputerPart[] {new Mouse(), new Keyboard(), new Monitor()};
    }


    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
